a11y: Check whether a widget is mapped before querying its parent
authorMike Gorse <mgorse@suse.com>
Fri, 30 Aug 2013 14:13:39 +0000 (09:13 -0500)
committerMike Gorse <mgorse@suse.com>
Sat, 31 Aug 2013 21:42:07 +0000 (16:42 -0500)
Call gtk_widget_get_mapped() in a couple of places before looking at the
widget's parent, since it might be set to a widget that has been
finalized, causing an invalid read.

gtk/a11y/gtkwidgetaccessible.c

index 841ae14e3cbced74ddfaba5afbdd0c9f179ef865..3572e42a1760c3ec6925112c08baf894a2ce0b26 100644 (file)
@@ -271,7 +271,7 @@ gtk_widget_accessible_ref_relation_set (AtkObject *obj)
       label = find_label (widget);
       if (label == NULL)
         {
-          if (GTK_IS_BUTTON (widget))
+          if (GTK_IS_BUTTON (widget) && gtk_widget_get_mapped (widget))
             /*
              * Handle the case where GnomeIconEntry is the mnemonic widget.
              * The GtkButton which is a grandchild of the GnomeIconEntry
@@ -781,6 +781,9 @@ gtk_widget_accessible_on_screen (GtkWidget *widget)
 
   gtk_widget_get_allocation (widget, &allocation);
 
+  if (!gtk_widget_get_mapped (widget))
+    return FALSE;
+
   viewport = gtk_widget_get_ancestor (widget, GTK_TYPE_VIEWPORT);
   if (viewport)
     {